import java.util.Arrays;
public class Test {
    public static void main(String[] args) {
        int []array={1,2,3};
        transform(array);
    }
    public static void transform(int []array){
        for (int i = 0; i < array.length; i++) {
            array[i]=array[i]*2;                              //将每个数组里元素的值都扩大两倍
        }
        System.out.println(Arrays.toString(array));
    }

public class Test {
    public static void main(String[] args) {
        int []array={1,6,5,4,9,7,15};
        System.out.println(binarySearch(array,7));
    }

    public static int binarySearch(int[] array, int date) {
        int left=0;
        int right= array.length-1;
        while(left<=right){
            int mid=(left+right)/2;
            if(date<array[mid]){
                right=mid-1;
            } else if (date>array[mid]){                 //二分查找
                left=mid+1;
            }else{
                return mid;
            }
        }
        return -1;
    }
}
public class Test {
    public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 5, 6};
        adjust(array);
    }
    public static void adjust ( int[] array){
        int j = 0;
        for (int i = 0; i < array.length; i++) {
            if (array[i]%2!= 0) {                          //实现奇数在前，偶数在后
                int temp = array[i];
                array[i] = array[j];
                array[j] = temp;
                j++;
            }
        }
        System.out.println(Arrays.toString(array));
    }
}
public class Test {
    public static void main(String[] args) {
        int []array={5,2,0,1,3,8,10};
        bubbleSort(array);
    }
    public static void bubbleSort(int []array){
        for (int i = 0; i < array.length-1; i++) {
            for (int j = 0; j <array.length-1-i; j++) {
                if(array[j]>array[j+1]){
                    int temp=array[j];
                    array[j]=array[j+1];          //冒泡排序
                    array[j+1]=temp;
                }
            }
        }
        System.out.println(Arrays.toString(array));
    }
}
public class Test {
    public static void main(String[] args) {
        int[] array = {1, 2, 5, 9, 8, 15};
        int target = 7;
        int []result=twoSum(array,target);
        for (int k = 0; k < result.length; k++) {
            System.out.println(result[k]);
        }
    }public static int[]twoSum(int []array,int date){
        for (int i= 0; i< array.length-1; i++) {
            for (int j = i+1; j < array.length; j++) {
                if(array[i]+array[j]==date){             //给定一个整数数组 array 和一个整数目标值 target，请你在该数组中找出
                                                          // 和为目标值 target 的那 两个 整数，并返回它们的数组下标
                    return new int []{i,j};
                }
            }
        }
        return null;
    }
}


public class Test {
    public static void main(String[] args) {
        int[] arr = {1, 3, 5, 3, 1};
        search(arr);
    }

    public static void search(int[] arr) {
        int result =0;
        for (int i = 0; i < arr.length ; i++) {
            result=result^arr[i];                 //数组中成单的那个元素
        }
        System.out.println(result);
            }
        }

public class Test {
    public static void main(String[] args) {
        int []arr={2,5,2,5,2,2};
        Arrays.sort(arr);
        System.out.println(arr[arr.length/2]);      //查找数组里面出现次数最多的那个元素，并将其打印下来
    }
}
public class Test {
    public static void main(String[] args) {
        int []arr={1,2,5,6,8,9,7,15};
        System.out.println(Search(arr));
    }
    public static boolean Search(int []arr) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 != 0 && arr[i + 1] % 2 != 0 && arr[i + 2] % 2 != 0) {
                return true;
            }                                     //判断是否有三个连续的奇数
            }return   false;
        }
    }

